package com.lepu.app.fun.chat.activity;

import java.util.List;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ListView;

import com.app.utils.LoginUtil;
import com.core.lib.application.BaseFragmentActivity;
import com.lepu.app.fun.chat.adapter.DoctorMainNoticeAdapter;
import com.lepu.app.fun.chat.bean.BeanDoctorNotice;
import com.lepu.app.widget.CustomTopBarNew;
import com.lepu.app.widget.CustomTopBarNew.OnTopbarNewLeftLayoutListener;
import com.lepu.pasm.R;

public class DoctorMainNoticeActivity extends BaseFragmentActivity implements
		OnTopbarNewLeftLayoutListener {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.chat_doctor_main_notice_activity);

		init();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	/**
	 * 添加页面动画，需要重写这个方法，
	 */
	@Override
	public void onBackPressed() {
		finish(true);
	}

	@Override
	public void onTopbarLeftLayoutSelected() {
		finish(true);
	}

	/**
	 * 初始化方法
	 */
	private void init() {
		// topbar
		CustomTopBarNew topbar = (CustomTopBarNew) findViewById(R.id.topbar);
		topbar.setTopbarTitle("公告板");
		topbar.setonTopbarNewLeftLayoutListener(this);

		List<BeanDoctorNotice> dataArrayList = BeanDoctorNotice
				.getNoticeListItem(LoginUtil.getUserId());

		ListView dataListView = (ListView) findViewById(R.id.dataListView);
		DoctorMainNoticeAdapter dataAdapter = new DoctorMainNoticeAdapter(this,
				dataArrayList);
		dataListView.setAdapter(dataAdapter);

		showHideNoDataLayout(true, dataArrayList);
	}

	private void showHideNoDataLayout(boolean isShow,
			List<BeanDoctorNotice> dataArrayList) {
		LinearLayout noDataLayout = (LinearLayout) findViewById(R.id.noDataLayout);
		if (noDataLayout != null) {
			if (isShow) {
				if (dataArrayList == null || dataArrayList.size() == 0) {
					noDataLayout.setVisibility(View.VISIBLE);
				}
			} else {
				noDataLayout.setVisibility(View.GONE);
			}
		}
	}

}
